#ifndef _ICCRF_H
#define _ICCRF_H


#if WIN32

#define uchar unsigned char 
#define ulong unsigned long 
#define uint unsigned int 

#define ICCRF_API __declspec(dllimport)

#endif





#define BPS9600		0
#define BPS19200	1
#define BPS38400	2
#define BPS57600	3
#define BPS115200	4


#define CARD_5V		0	//5v
#define CARD_18V	1	//1.8v
#define CARD_3V		2	//3v

#include "utiledef.h"

//-----------------------------------------------------------------------------------------------
//�豸��������
//-----------------------------------------------------------------------------------------------

ICCRF_API  int WINAPI   rf_beep(HANDLE  icdev,uint _Msec);
ICCRF_API  int WINAPI   rf_get_status(HANDLE icdev,uchar * _Status);
ICCRF_API  int WINAPI   rf_lib_ver(uchar *buff);
 
//-----------------------------------------------------------------------------------------------
//ͨ�ú���
//-----------------------------------------------------------------------------------------------

ICCRF_API  HANDLE WINAPI   rf_init(int  icdev,long baud);
ICCRF_API  int WINAPI  rf_exit(HANDLE icdev);
ICCRF_API  int WINAPI  rf_card(HANDLE  icdev,uchar _Mode,ulong *_Snr);
ICCRF_API  int WINAPI  rf_config(HANDLE  icdev,uchar _Mode,uchar _Baud);
ICCRF_API  int WINAPI  rf_request(HANDLE  icdev,uchar _Mode,uchar *TagType);
ICCRF_API  int WINAPI  rf_anticoll(HANDLE  icdev,uchar _Bcnt,ulong *_Snr);
ICCRF_API  int WINAPI  rf_select(HANDLE  icdev,ulong _Snr,uchar *_Size);
ICCRF_API  int WINAPI  rf_load_key(HANDLE  icdev,uchar _Mode,uchar _SecNr,uchar *_Nkey);
ICCRF_API  int WINAPI  rf_load_key_hex(HANDLE  icdev,uchar _Mode,uchar _SecNr,uchar *_NKey);
ICCRF_API  int WINAPI  rf_halt(HANDLE  icdev);
ICCRF_API  int WINAPI  rf_read(HANDLE  icdev,uchar _Adr,uchar *_Data);
ICCRF_API  int WINAPI  rf_read_hex(HANDLE  icdev,uchar _Adr,uchar *_Data);
ICCRF_API  int WINAPI  rf_write(HANDLE  icdev,uchar _Adr,uchar *_Data);
ICCRF_API  int WINAPI  rf_write_hex(HANDLE  icdev,uchar _Adr,uchar *_Data);
ICCRF_API  int WINAPI  rf_check_write(HANDLE  icdev,ulong Snr,uchar authmode,uchar Adr,uchar *_Data);
ICCRF_API  int WINAPI  rf_check_writehex(HANDLE  icdev,ulong Snr,uchar authmode,uchar Adr,uchar *_Data);
 
//-----------------------------------------------------------------------------------------------
//M1��ר�ú���
//-----------------------------------------------------------------------------------------------

ICCRF_API  int WINAPI  	rf_authentication(HANDLE  icdev,uchar _Mode,uchar _SecNr);
ICCRF_API  int WINAPI  	rf_changeb3(HANDLE  icdev,uchar _SecNr,uchar *_KeyA,uchar _B0,uchar _B1,uchar _B2,uchar _B3, uchar _Bk,uchar *_KeyB);
ICCRF_API  int WINAPI   rf_initval(HANDLE icdev,uchar _Adr,ulong _Value);
ICCRF_API  int WINAPI   rf_increment(HANDLE icdev,uchar _Adr,ulong _Value);
ICCRF_API  int WINAPI   rf_decrement(HANDLE icdev,uchar _Adr,ulong _Value);
ICCRF_API  int WINAPI   rf_readval(HANDLE icdev,uchar _Adr,ulong *_Value);
ICCRF_API  int WINAPI   rf_restore(HANDLE icdev,uchar _Adr);
ICCRF_API  int WINAPI   rf_transfer(HANDLE icdev,uchar _Adr);
              
//-----------------------------------------------------------------------------------------------
//M1���߼�����
//-----------------------------------------------------------------------------------------------

ICCRF_API  	int WINAPI  rf_HL_authentication(HANDLE  icdev,uchar reqmode,ulong snr, uchar authmode,uchar secnr);
ICCRF_API  	int WINAPI  rf_HL_read(HANDLE  icdev,uchar _Mode,uchar _Adr,ulong _Snr,uchar *_Data,ulong *_NSnr);
ICCRF_API  	int WINAPI  rf_HL_readhex(HANDLE  icdev,uchar _Mode,uchar _Adr,ulong _Snr,uchar *_Data,ulong *_NSnr);
ICCRF_API  	int WINAPI  rf_HL_write(HANDLE  icdev,uchar _Mode,uchar _Adr,ulong _Snr,uchar *_Data);
ICCRF_API  	int WINAPI  rf_HL_writehex(HANDLE  icdev,uchar _Mode,uchar _Adr, ulong _Snr,uchar *_Data);
ICCRF_API  	int WINAPI  rf_HL_initval(HANDLE  icdev,uchar _Mode,uchar _SecNr,ulong _Value,ulong *_Snr);
ICCRF_API  	int WINAPI  rf_HL_increment(HANDLE  icdev,uchar _Mode,uchar _SecNr,ulong _Value,ulong _Snr,ulong *_NValue,ulong *_NSnr);
ICCRF_API  	int WINAPI  rf_HL_decrement(HANDLE  icdev,uchar _Mode,uchar _SecNr,ulong _Value,ulong _Snr,ulong *_NValue,ulong *_NSnr);
ICCRF_API 	int WINAPI 	rf_readM(HANDLE  icdev,uchar _Adr,uchar _Nm,uchar *_Data);  
ICCRF_API 	int WINAPI 	rf_writeM(HANDLE  icdev,uchar _Adr,uchar _Nm,uchar *_Data);             
//-----------------------------------------------------------------------------------------------
//ML��ר�ú���
//-----------------------------------------------------------------------------------------------
ICCRF_API  int WINAPI  	rf_authentication_2(HANDLE  icdev,uchar _Mode,uchar KeyNr,uchar Adr);
ICCRF_API  int WINAPI   rf_initval_ml(HANDLE icdev,uint _Value);
ICCRF_API  int WINAPI   rf_readval_ml(HANDLE icdev,uint *_Value);
ICCRF_API  int WINAPI  	rf_decrement_transfer(HANDLE icdev,uchar Adr,ulong _Value);
ICCRF_API  int WINAPI 	rf_change_ml(HANDLE  icdev,uchar _Mode,ulong _Snr,	uchar *_KeyA,uchar _AC0,uchar _AC1,uchar *_KeyB,ulong *_NSnr);
  
//-----------------------------------------------------------------------------------------------
//14443 ��׼�ӿ�		
//-----------------------------------------------------------------------------------------------
ICCRF_API  int WINAPI   rf_ISO14443A_request(HANDLE icdev,uchar rmode,uchar *atq);
ICCRF_API  int WINAPI   rf_ISO14443A_anticoll(HANDLE icdev,uchar cmd,uchar *snr);
ICCRF_API  int WINAPI   rf_ISO14443A_select(HANDLE icdev,uchar cmd,uchar *snr);
ICCRF_API  int WINAPI 	rf_ISO14443A_findcard(HANDLE icdev,uchar wmode,uchar *len,uchar *serial_nm);
ICCRF_API  int WINAPI  	rf_ISO14443A_ATS(HANDLE icdev,uchar *len,uchar *rats);
ICCRF_API  int WINAPI  	rf_ISO14443A_APDU(HANDLE icdev,unsigned char slen,unsigned char *sbuf,unsigned char *rlen, unsigned char *rbuf);
ICCRF_API  int WINAPI  	rf_ISO14443A_Deselect(HANDLE icdev);
 //-----------------------------------------------------------------------------------------------
//Ultralight CARD
//-----------------------------------------------------------------------------------------------
ICCRF_API  int WINAPI  rf_UL_findcard(HANDLE icdev,uchar wmode,uchar *len,uchar *serial_nm);
ICCRF_API  int WINAPI  rf_UL_read(HANDLE  icdev,uchar _Adr,uchar *_Data);
ICCRF_API  int WINAPI  rf_UL_write(HANDLE  icdev,uchar _Adr,uchar *_Data);

ICCRF_API  int WINAPI  rf_UL_readM(HANDLE  icdev,uchar _Adr,uchar _Nm,uchar *_Data);
ICCRF_API  int WINAPI  rf_UL_writeM(HANDLE  icdev,uchar _Adr,uchar _Nm,uchar *_Data);

ICCRF_API  int WINAPI  rf_rfinf_reset(HANDLE icdev,uchar rflag);


ICCRF_API  int WINAPI des_code(unsigned char k,unsigned char *pdata,unsigned char * dkey,unsigned char *res);
ICCRF_API  int WINAPI des3_code(unsigned char k,unsigned char *pdata,unsigned char * dkey,unsigned char *res);

ICCRF_API int WINAPI rf_outputIO(HANDLE  icdev,uchar o_NO,uchar o_lev);
ICCRF_API int WINAPI rf_changbps(HANDLE  icdev,long baud);
ICCRF_API int WINAPI rf_inputIO(HANDLE  icdev,uchar *o_lev);
ICCRF_API int WINAPI rf_autoread(HANDLE  icdev,long flg); 
//-----------------------------------------------------------------------------------------------
//125K CARD
//-----------------------------------------------------------------------------------------------
ICCRF_API HANDLE WINAPI rf_init_125KCard(int icdev,long baud);
ICCRF_API int   WINAPI	rf_read_125Card_hex(HANDLE  icdev,uchar *_Data);

ICCRF_API int  WINAPI rf_PowerRFIDOff();
ICCRF_API int  WINAPI rf_PowerRFIDON();
//-----------------------------------------------------------------------------------------------
//cpu��
//-----------------------------------------------------------------------------------------------
ICCRF_API long WINAPI cpu_test(HANDLE icdev);	
ICCRF_API long WINAPI cpu_reset(HANDLE icdev,unsigned long  *rlen,unsigned char  *buf);
ICCRF_API long WINAPI cpu_power_off(HANDLE icdev);
ICCRF_API ulong  WINAPI cpu_access(HANDLE icdev,unsigned char slen,unsigned char  *send,unsigned char *rlen,unsigned char *receive);
ICCRF_API long WINAPI cpu_selsocket(HANDLE icdev,unsigned char  samso);
ICCRF_API long WINAPI cpu_getsocket(HANDLE icdev,unsigned char  *samso );
ICCRF_API long WINAPI cpu_reset2(HANDLE icdev,unsigned char baud,unsigned char ucVoltage ,unsigned long  *rlen,unsigned char  *buf);         
//-----------------------------------------------------------------------------------------------
//ISO15693 CARD
//-----------------------------------------------------------------------------------------------

ICCRF_API int WINAPI ISO15693_Inventory(HANDLE icdev,unsigned char flags,unsigned char AFI,unsigned char masklengh ,unsigned char *maskvalue,unsigned char*databuffer);
ICCRF_API int WINAPI ISO15693_Stay_Quiet(HANDLE icdev,unsigned char flags,unsigned char*UID);
ICCRF_API int WINAPI ISO15693_Read(HANDLE icdev,unsigned char flags,unsigned char Firstblock, unsigned char Number,unsigned char*UID,unsigned char*databuffer);
ICCRF_API int WINAPI ISO15693_Write(HANDLE icdev,unsigned char flags,unsigned char Firstblock,unsigned char Number,unsigned char*UID,unsigned char*databuffer);
ICCRF_API int WINAPI ISO15693_Lock_Block(HANDLE icdev,unsigned char flags,unsigned char block,unsigned char*UID);
ICCRF_API int WINAPI ISO15693_Select(HANDLE icdev,unsigned char flags,unsigned char*UID);
ICCRF_API int WINAPI ISO15693_Reset_To_Ready(HANDLE icdev,unsigned char flags,unsigned char*UID);
ICCRF_API int WINAPI ISO15693_Write_AFI(HANDLE icdev,unsigned char flags, unsigned char AFI, unsigned char*UID);
ICCRF_API int WINAPI ISO15693_Lock_AFI(HANDLE icdev,unsigned char flags,unsigned char*UID);
ICCRF_API int WINAPI ISO15693_Write_DSFID(HANDLE icdev,unsigned char flags,unsigned char DSFID,unsigned char*UID);
ICCRF_API int WINAPI ISO15693_Lock_DSFID(HANDLE icdev,unsigned char flags,unsigned char*UID);
ICCRF_API int WINAPI ISO15693_GET_System_Information(HANDLE icdev,unsigned char flags,unsigned char*UID,unsigned char *databuffer);
ICCRF_API int WINAPI ISO15693_GetMultipleBlockSecurity(HANDLE icdev,unsigned char flags,unsigned char Firstblock,unsigned char Number,unsigned char*UID,unsigned char*databuffer);
ICCRF_API int WINAPI ISO15693_Generic(HANDLE icdev,unsigned char length,unsigned char *databuffer);

ICCRF_API int WINAPI barcode_trig(HANDLE  icdev,uchar ms);
ICCRF_API int WINAPI barcode_read(HANDLE  icdev,int ms,uchar *_Data);

#endif
